package cemp.mapper;

import cemp.entity.StockKpiDay;
import cemp.entity.StockPlate;
import cemp.extension.ExtensionMapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author xsb_t
* @description 针对表【stock_kpi_day】的数据库操作Mapper
* @createDate 2024-11-08 13:06:13
* @Entity cemp.entity.StockKpiDay
*/
public interface StockKpiDayMapper extends ExtensionMapper<StockKpiDay> {

    //@Select("select biz_device_id from tb_device_iot where deleted = 0 and biz_product_id= #{pkId} and source_device_id= #{sourceDevId} limit 1")
    //String queryBizDeviceIdByOuterId(@Param("gateId") String gateId, @Param("pkId") String pkId, @Param("sourceDevId") String sourceDevId);
    @Select("select * from stock_kpi_day where stock_code = #{stockCode} and sta_date = #{date} limit 1")
    StockKpiDay findOneDay(@Param("stockCode")String stockCode, @Param("date")String date);

    @Select("select * from stock_kpi_day where stock_code = #{stockCode} order by sta_date limit 1")
    StockKpiDay findOneLastDay(@Param("stockCode")String stockCod);

    @Select("select * from stock_kpi_day t1 where t1.stock_code = #{stockCode} and t1.sta_date < #{sta} limit  #{days}")
    List<StockKpiDay> getLatest(@Param("stockCode")String stockCode,@Param("sta")String sta, @Param("days")Integer days);

    @Select("select * from stock_kpi_day t1 where t1.sta_date > #{startDate} and t1.sta_date < #{endDate}")
    List<StockKpiDay> getLatest2(@Param("startDate")String startDate, @Param("endDate")String endDate);

    @Select("select * from stock_kpi_day t1 where t1.sta_date < #{endDate} limit #{days}")
    List<StockKpiDay> getLatest3( @Param("endDate")String endDate,@Param("days")Integer days);
}




